package com.wangsd.web.sys.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户表
 */
@Data
@Entity
@Table(name = "sys_user")
@ApiModel(value = "用户", description = "用户")
public class SysUser implements Serializable {

    @ApiModelProperty(value = "id")
    @Id//JPA指定id
    /*mybatis plus 自增主键*/
    @TableId(type = IdType.AUTO)
    /*jpa 生成自增策略*/
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /*在表中某个字段后追加字段示例*/
    //@ApiModelProperty(value = "test")
    //@Column(name = "test", columnDefinition = "int(1) default 0 not null after id")
    //private String test;

    @ApiModelProperty(value = "创建时间")

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT)
    private Date createdTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updatedTime;

    @ApiModelProperty(value = "（逻辑删除）是否已删；0，未删，1，已删")
    @TableField(fill = FieldFill.INSERT)
    private Integer deleted;

    @ApiModelProperty(value = "真实姓名")
    private String realName;

    @ApiModelProperty(value = "通用通公众号OPENID")
    private String openId;

    @ApiModelProperty(value = "用户名称")
    private String username;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "0,禁用，1，启用")
    private boolean status;

    @ApiModelProperty(value = "父级id")
    private Long parentId;

    @ApiModelProperty(value = "用户类型；99，超级管理员；1，服务商；2，代理商；3，商户；4，门店；5，店员")
    private Integer type;

    /*所有父级目录*/
    private String code;

    @ApiModelProperty(value = "极光注册ID")
    private String registrationId;

    @ApiModelProperty(value = "扩展角色id")
    @Transient
    @TableField(exist = false)
    private List<Long> roleIds;

    @ApiModelProperty(value = "公司名称")
    @Transient
    @TableField(exist = false)
    private String companyName;

    @ApiModelProperty(value = "用户拥有哪些菜单")
    @Transient
    @TableField(exist = false)
    private List<SysMenu> menuList;

    @ApiModelProperty(value = "用户拥有哪些权限")
    @Transient
    @TableField(exist = false)
    private List<String> permissionList;

    @ApiModelProperty(value = "服务商名称")
    @Transient
    @TableField(exist = false)
    private String businessName;

    @ApiModelProperty(value = "代理商名称")
    @Transient
    @TableField(exist = false)
    private String agentName;

    @ApiModelProperty(value = "商户名称")
    @Transient
    @TableField(exist = false)
    private String merchantName;

    @ApiModelProperty(value = "门店名称")
    @Transient
    @TableField(exist = false)
    private String storeName;
}
